package com.acwing.partition36;

import java.io.*;
import java.util.HashSet;
import java.util.Set;

/**
 * @author rkc
 * @date 2022/7/18 9:49
 */
public class AC3511倒水问题 {

    private static final long BASE = 10000;
    private static Set<Long> states = new HashSet<>();
    private static Set<Integer> set = new HashSet<>();
    private static int[] c = new int[3];

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        while (true) {
            String s = reader.readLine();
            if (s == null || s.isEmpty()) break;
            states.clear();
            set.clear();
            String[] ss = s.split(" ");
            c[0] = Integer.parseInt(ss[0]); c[1] = Integer.parseInt(ss[1]); c[2] = Integer.parseInt(ss[2]);
            int[] cur = {0, 0, c[2]};
            dfs(cur);
            writer.write(set.size() + "\n");
        }
        writer.flush();
    }

    private static void dfs(int[] cur) {
        states.add(get(cur));
        set.add(cur[2]);
        int[] temp = new int[3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (i != j) {
                    //拷贝一份，对拷贝的状态进行操作并dfs，这样就不用在原有状态上进行恢复现场
                    System.arraycopy(cur, 0, temp, 0, cur.length);
                    pour(temp, i, j);
                    if (states.contains(get(temp))) continue;
                    dfs(temp);
                }
            }
        }
    }

    private static void pour(int[] cur, int i, int j) {
        int t = Math.min(cur[i], c[j] - cur[j]);
        cur[i] -= t;
        cur[j] += t;
    }

    private static long get(int[] c) {
        return c[2] * BASE * BASE + c[1] * BASE + c[0];
    }
}
